import os

def call_command(cmd):
    print("call_command ", cmd)
    code = os.system(cmd)
    if code != 0:
        print('call_command failed! ', cmd, " code:", code)
        return False
    return True

call_command("cd ..")
print("丢弃本地更改 & 初始化子模块 & 丢弃子模块更改")
call_command("git clean -df")
call_command("git reset --hard")
call_command("git checkout .")
call_command("git submodule update --init --recursive")
call_command("git submodule foreach git checkout .")
print("拉取代码 & 切换分支")
call_command("git pull")
call_command("git checkout ${branch}")
print("拉取当前分支代码 & 更新子模块")
call_command("git pull")
call_command("git submodule update --init --recursive")
call_command("git submodule foreach git checkout master")
call_command("git submodule foreach git checkout .")
call_command("git submodule foreach git clean -df")
call_command("git submodule foreach git reset --hard")
call_command("git submodule foreach git pull")
call_command("git submodule update")
